<?php
/**
 * Created by PhpStorm.
 * User: yangyou
 * Class Designer
 * 设计师模型
 * Date: 2018/12/5 0005
 * Time: 15:23
 */

namespace app\index\model;


class Designer extends Base
{
    /**
     * Author:yang you
     * Time:2018-12-2 10:27:51
     * Describe:设计师列表
     * @param string designer_level
     * @param string $cate
     * @param string $layct
     * @return int|string
     */
    public function designerList($designer_level = "",$after_limit = "12"){
        return $this->where(function ($q)use ($designer_level){
                if(!empty($designer_level)){
                    //查找该等级设计师
                    $q->where("designer_level",$designer_level);
                }
            })
            ->where('is_display',1)
            ->orderRaw("sort DESC")
            ->paginate($after_limit,false,[
                'type'     => 'page\marketPage',
                'var_page'  => 'p',
                'query' =>  request()->param(),
            ]);
    }

    /**
     * Author:yang you
     * Time:2018-12-2 10:27:51
     * Describe:设计师列表
     * @param string designer_level
     * @param string $cate
     * @param string $layct
     * @return int|string
     */
    public function team($limit = "10"){
        return $this->field('photo,designer_name,designer_level_name,years,designer_id')->where('is_display',1)
            ->orderRaw("sort DESC")
            ->limit($limit)
            ->select();
    }

    /**
     * Author:yang you
     * Time:2018-12-2 10:27:51
     * Describe:随机获取设计师信息
     * @return int|string
     */
    public function randInfo(){
        return $this->alias("a")->field("a.*")
            ->orderRaw('rand()')
            ->limit(1)
            ->find();
    }


}